<script type="text/javascript">

    function serilizeURL(url) {
        var rs = url.split("?")[1];
        var arr = rs.split("&");
        var json = {};
        for (var i = 0; i < arr.length; i++) {
            if (arr[i].indexOf("=") != -1) {
                json[arr[i].split("=")[0]] = arr[i].split("=")[1];
            }
            else {
                json[arr[i]] = "undefined";
            }
        }

        return json;
    }



    function getAllColumnList() {
        var FirstLevelColumnList;
        var FirstLevelColumnListLength;
        var url = location.href;
        if (url.split("?")[1] && url.split("?")[1].split("&")) {
            var pid = serilizeURL(url).pid;
        }
        $.ajax({
            url: "http://192.168.100.181:8080/api/columnInfo/getAllColumnList",

            success: function (data) {

                FirstLevelColumnList = data.data;
                localStorage.setItem('getAllColumnList', JSON.stringify(FirstLevelColumnList));
                FirstLevelColumnListLength = FirstLevelColumnList.length;

                for (var i = 0; i < FirstLevelColumnListLength; i++) {
                    $('#j_dy_active').append('<li id=' + FirstLevelColumnList[i].id + '><a href=http://192.168.100.181:8080/huoge-edu/' + FirstLevelColumnList[i].typeUrl + '?pid='+FirstLevelColumnList[i].id+'&secondMenuId='+FirstLevelColumnList[i].secondMenuId+'>' + FirstLevelColumnList[i].name + '</li>');
                    $('#mobile-nav').append('<li id=mnav' + FirstLevelColumnList[i].id + '><a href=http://192.168.100.181:8080/huoge-edu/' + FirstLevelColumnList[i].typeUrl + '?pid='+FirstLevelColumnList[i].id+'&secondMenuId='+FirstLevelColumnList[i].secondMenuId+'>' + FirstLevelColumnList[i].name + '</li>');
                    if (pid && pid === FirstLevelColumnList[i].id) {
                        $('#' + FirstLevelColumnList[i].id).addClass('active');
                        $('#mnav' + FirstLevelColumnList[i].id).addClass('active');
                    } else if (undefined == pid) {
                        $('#' + FirstLevelColumnList[0].id).addClass('active');
                        $('#mnav' + FirstLevelColumnList[0].id).addClass('active');
                    }
                }
            }
        });
    }

    function getPictures(id, param,limit) {
        var picturesLists;
        var picturesListsLength;
        $.ajax({
            url: "http://192.168.100.181:8080/api/banner/"+id+"/"+param+"/"+limit,

            success: function (data) {
                picturesLists=data.data;
                picturesListsLength=picturesLists.length;


                if('head'==param){
                    for (var i = 0; i < picturesListsLength; i++) {
                        var piclist=`<li><img src=${picturesLists[i].bannerImg} alt="03"></li>`;
                        $('.banner #index-top-slide').append($(piclist).hide().fadeIn(800))
                    }

                }else {
                    for (var i = 0; i < picturesListsLength; i++) {
                        alists[i].href='#'+picturesLists[i].id;
                        $('.dy-main .tab-content.j_tab_slider').append(`
                          <div class="dy-main-1 tab-huanbao" id=${picturesLists[i].id} style="background-image: url(${picturesLists[i].bannerImg});background-repeat: no-repeat;height: 690px;">
                                        <div class="container" style="padding: 0">
                                        <h3 class="home-left">${alists[i].text}</h3>

                           </div>`)
                    }
                }
            }});
    }



    function getArticleIndex() {
        var articleLists;
        var articleListsLength;
        $.ajax({
            url: "http://192.168.100.181:8080/api/article/index",
            success: function (data) {
                articleLists=data.data;
                articleListsLength=articleLists.length;
                for (var i = 0; i < articleListsLength; i++) {


                    $('.j_project_slider').append(`
                            <div class="pic-slider">
                                <a href="http://192.168.100.181:8080/huoge-edu/common/article-details.html?pid=${articleLists[i].rootColumnInfoId}&secondMenuId=${articleLists[i].columnInfoId}&articleId=${articleLists[i].id}">
                                    <img src=${articleLists[i].coverImageUrl}>
                                    <div class="pic-title">${articleLists[i].title}</div>
                                </a>
                            </div>`)

                    $('.j_revise-text_slider').append(`
                            <a href="http://192.168.100.181:8080/huoge-edu/common/article-details.html?pid=${articleLists[i].rootColumnInfoId}&secondMenuId=${articleLists[i].columnInfoId}&articleId=${articleLists[i].id}" class="clearfix ">
                                <div class="text">
                                    <p class="font-14 mb-1">${articleLists[i].title}</p>
                                    <p class="time font-14">${articleLists[i].createDate}</p>
                                </div>
                            </a>`)
                }
            }});

    }

    function getFragment(param) {
        var getFragmentLists;
        var getFragmentLength;

        $.ajax({
            url: "http://192.168.100.181:8080/api/fragment/1/"+param,

            success: function (data) {
                getFragmentLists=data.data;
                getFragmentLength=getFragmentLists.length;
                if("body"==param){
                    $('.pengxin-news').append(getFragmentLists)
                }else if("1body"==param){
                    $('.dy-tions').append(getFragmentLists)
                }else if("2body"==param){
                    $('.dy-pic').append(getFragmentLists)
                }

            }});
    }


    $(document).ready(function () {



        getAllColumnList();
        getPictures(1,"head",7);
        getArticleIndex();
        getFragment('body');
        getFragment('1body');
        getFragment('2body');

        setTimeout(function () {

            alists=$('.dy-side-nav.j_tab.list-paddingleft-2 a');
            getPictures(1,"head-02",10);
        },1000)
    })
</script>
<header class="header">
    <div class="dy-header-nav clearfix do-top-bar">
        <div class="dy-logo do-logo hidden-xs"><a href="index.html"><img src="http://192.168.100.181:8080/huoge-edu/src/img/logo.png" alt=""></a></div>
        <div class="dy-nav main-nav-w clearfix hidden-xs">
            <ul class="clearfix main-nav" id="j_dy_active">
            </ul>
        </div>
        <div class="dy-language-chosse do-lang hidden-xs">
            <a href="javascript:;"><i class="iconfont icon-en"></i></a>
            <a class="hidden-xs" href=""><i class="iconfont icon-zhanghu"></i></a>
        </div>

        <!--移动端导航 开始-->
        <div class="visible-xs px-mobile">
            <div class="dy-logo do-logo mobile-logo"><a href="index.html"><img src="http://192.168.100.181:8080/huoge-edu/src/img/logo.png" alt=""></a>
            </div>
            <div class="dy-language-chosse do-lang">
                <a href="javascript:;"><i class="iconfont icon-en"></i></a>
            </div>
            <div class="dy-nav main-nav-w clearfix">
                <button class="bread" type="button" id="dropdownMenu2">
                    <i class="icon-bar"></i>
                    <i class="icon-bar"></i>
                    <i class="icon-bar"></i>
                </button>
                <ul class="clearfix main-nav" id="mobile-nav">
                </ul>
            </div>
        </div>
        <!--移动端导航 结束-->

    </div>
</header>

